<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib prefix="s" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%> 
<%@ include file="../../../../header.jsp"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>

<style>
#closemonth-form {
	display: table;
	margin:0 auto;
}

.table-row {
	display: table-row;
	height:32px;
}
.ui-input{
	width: 200px;
}
.table-row>* {
	display: table-cell;
	margin-left: 20px;
	vertical-align: middle;
}
.table-row>label{
	text-align: right;
}

</style>
</head>
<body style="align: center;">
	<div style="margin-top: 10px; margin-left: 30px;">
		<form id="closemonth-form" action="">
			<div style="margin-left: 10px;">
				<div class="table-row">
					<label for="jobcode">id</label> 
					<input type="text" style="width: 120px; height: 28px;" disabled="disabled" class="ui-input" name="id" id="id" >
				</div>
				<div class="table-row">
					<label for="jobcode">公司:</label>
					<input type="text" style="width: 120px; height: 28px;" disabled="disabled" class="ui-input" name="comopanyid" id="comopanyid"> 
				</div>
				<div class="table-row">
					<label for="jobcode">年:</label> 
					<input type="text" style="width: 120px; height: 28px;" disabled="disabled" class="ui-input" name="year" id="year">
				</div>
				<div class="table-row">
					<label for="jobcode">月:</label> 
					<input type="text" style="width: 120px; height: 28px;" disabled="disabled" class="ui-input" name="month" id="month">
				</div>
				<div class="table-row">
					<label for="jobcode">月结标志:</label> 
					<div id="mcloseflag">
						<input  class="switch-simple-3" id="switch_mcloseflag" type="checkbox" disabled="disabled"><label for="switch_mcloseflag" class="green"></label>
					</div>
				</div>
				<div class="table-row">
					<label for="jobcode">月结时间:</label> 
					<input type="text" style="width: 120px; height: 28px;" disabled="disabled" class="ui-input" name="mclosedate" id="mclosedate">
				</div>
				<div class="table-row">
					<label for="jobcode">月结人:</label> 
					<input type="text" style="width: 120px; height: 28px;" disabled="disabled" class="ui-input" name="muserid" id="muserid">
				</div>
			</div>
		</form>
	</div>
<script type="text/javascript">
var api=frameElement.api;
var operate=api.data.operate;
var rowid=api.data.rowid;
var rowdata=api.data.rowdata;
var CallBack=api.data.callback;
$(function(){
	initPopBtns();
	$("#id").val(rowdata.id);
	$("#comopanyid").val(rowdata.comopanyid);
	$("#year").val(rowdata.year);
	$("#month").val(rowdata.month);
	$("#mcloseflag").val(rowdata.mcloseflag);
	$("#mclosedate").val(rowdata.mclosedate);
	$("#muserid").val(rowdata.muserid);
})

function initPopBtns() {
	var btnname = ["月结", "取消"];
	api.button({
		id: "confirm",
		name: btnname[0],
		focus: true,
		callback: function(e) {
			var id=$("#id").val();
			var comopanyid=$("#comopanyid").val();
			var year=$("#year").val();
			var month=$("#month").val();
			var mcloseflag=$("#mcloseflag").val();
			var mclosedate=$("#mclosedate").val();
			var muserid=$("#muserid").val();
			$.ajax({
				url:encodeURI("kaoqinmonth/doClosemonth"),
				type:"POST",
				data:{
					"id":rowid,
					"comopanyid":comopanyid,
					"year":year,
					"month":month,
					"mcloseflag":mcloseflag,
					"mclosedate":mclosedate,
					"muserid":muserid,
				},
				async : false,//同步,坑爹啊。。
				success:function(data){
					if(data.status==200){
						parent.Public.tips({
							content: "月结成功!"
						})
						CallBack();
					}else if(data.status==400){
						parent.Public.tips({
							type:1,
							content: "已经月结过，无法再进行月结操作!"
						})
					}else if(data.status==600){
						parent.Public.tips({
							type:1,
							content: "上个月还没有月结，无法进行下个月的月结！"
						})
					}else if(data.status==777){
						parent.Public.tips({
							type:1,
							content: "你没有月结的权限！"
						})
					}else{
						parent.Public.tips({
							type:1,
							content: "月结失败:请假表中有未审批的请假记录！"
						})
					}		
				}
			});
			
		}
	}, {
		id: "cancel",
		name: btnname[1]
	})
}
</script>
</body>
</html>